import React from 'react'
import Menu from '@/components/Menu'

const Index = () => {
  // 退出登录
  const logout = async () => {
    // 弹出提示框
    var result = await React.UI.Dialog.confirm({
      content: '是否确认退出'
    })

    // 点击了确认
    if (result) {
      // 删除cookie
      React.Cookie.remove('business')

      // 跳转到登录界面
      React.navigate('/business/login')

      return false
    }
  }

  //判断是否显示邮箱认证
  const Email = (props: any) => {
    if (React.Business.auth == '0') {
      return (
        <div className="item">
          <React.Router.Link to={'/business/email'}>
            <div className="title">邮箱认证</div>
            <div className="icon">
              <img src="/assets/images/right.png" alt="" />
            </div>
          </React.Router.Link>
        </div>
      )
    } else {
      return (<></>)
    }
  }


  return (
    <>
      <link rel="stylesheet" href="/assets/css/user.css" />

      <div className="top"><div>个人中心</div></div>

      <div className="header">
        <div className="userinfo">
          <div className="avatar">
            <img src={React.Business.avatar_text} alt="" />
          </div>
          <div className="nickname">{React.Business.nickname}</div>
        </div>
        <div className="corrugated">
          <div className="wave-top wave-item"></div>
          <div className="wave-middle wave-item"></div>
          <div className="wave-bottom wave-item"></div>
        </div>
      </div>

      <div className="menu-cell">
        <div className="item">
          <React.Router.Link to={'/business/profile'}>
            <div className="title">个人资料</div>
            <div className="icon">
              <img src="/assets/images/right.png" alt="" />
            </div>
          </React.Router.Link>
        </div>

        <Email />

        <div className="item">
          <React.Router.Link to={"/guest/index"}>
            <div className="title">住客信息</div>
            <div className="icon">
              <img src="/assets/images/right.png" alt="" />
            </div>
          </React.Router.Link>
        </div>

        <div className="item">
          <React.Router.Link to={"/order/index"}>
            <div className="title">房间订单</div>
            <div className="icon">
              <img src="/assets/images/right.png" alt="" />
            </div>
          </React.Router.Link>
        </div>

        <div className="item">
          <React.Router.Link to={'/business/coupon'}>
            <div className="title">我的优惠券</div>
            <div className="icon">
              <img src="/assets/images/right.png" alt="" />
            </div>
          </React.Router.Link>
        </div>

        <div className="item">
          <React.Router.Link to={'/business/about'}>
            <div className="title">关于我们</div>
            <div className="icon">
              <img src="/assets/images/right.png" alt="" />
            </div>
          </React.Router.Link>
        </div>

        <div className="item" onClick={logout}>
          <a>
            <div className="title">退出登陆</div>
            <div className="icon">
              <img src="/assets/images/right.png" alt="" />
            </div>
          </a>
        </div>
      </div>

      <Menu />
    </>
  )
}

export default Index
